/*
三D编辑器主文件
*/
import React from 'react';
import ThreeD from './ThreeD/index';
import Renderer from './ThreeD/renderer';
import Loading from './ThreeD/loading';
import NoSupport from './ThreeD/noSupport';
import Scene from './ThreeD/scene';
import Camera from './ThreeD/camera';
import RayCaster from './ThreeD/rayCaster';
import Grids from './ThreeD/grids';
import StereoEditBar from './ThreeD/stereoEditBar';
import WidgetLoader from './ThreeD/Loaders/widgetLoader';
import BackgroundLoader from './ThreeD/Loaders/backgroundLoader';

const Stereo = (props) => {
    const { widgets, switchType, selectedPage: page, resources, 
        queryThreedState, selectWidgetsByIds, updateWidget } = props;
    let className = switchType === 'ThreedAR' && props.editorType !== '0' ? 'visible-status' : 'hidden-status';
    
    return ( 
        <ThreeD className={className}>
            <Renderer selectWidgetsByIds={selectWidgetsByIds} updateWidget={updateWidget}>
                <Scene>
                    <Grids />
                    <Camera />
                    <RayCaster />
                    <BackgroundLoader page={page} />
                    {widgets.map((widget, index) =>
                        <WidgetLoader key={index} widget={widget} resources={resources} queryThreedState={queryThreedState} />
                    )}
                </Scene>
            </Renderer> 
            <StereoEditBar />
            <Loading />
            <NoSupport />
      </ThreeD>
    )
}

export default Stereo;
